import DobotDllType as dType
import threading
import numpy as np

CON_STR = {
    dType.DobotConnect.DobotConnect_NoError: "DobotConnect_NoError",
    dType.DobotConnect.DobotConnect_NotFound: "DobotConnect_NotFound",
    dType.DobotConnect.DobotConnect_Occupied: "DobotConnect_Occupied"}

# 将dll读取到内存中并获取对应的CDLL实例
api = dType.load()
# 建立与dobot的连接
state = dType.ConnectDobot(api, "", 115200)[0]
print("Connect status:", CON_STR[state])

print('建立链接')
if state == dType.DobotConnect.DobotConnect_NoError:

    # 清空队列
    # Clean Command Queued
    dType.SetQueuedCmdClear(api)
    print('clean command')
    # 回零
    # Async Home
   # dType.SetHOMECmd(api, temp=0, isQueued=1)
    print('set home')
    # 开始执行指令队列
    # Start to Execute Command Queue
    dType.SetQueuedCmdStartExec(api)
    print('start command')

    # 停止执行指令
    # Stop to Execute Command Queued
    dType.SetQueuedCmdStopExec(api)
    print('stop command')
# 断开连接
# Disconnect Dobot
dType.DisconnectDobot(api)
print('disconncet dobot')